<?php

include_once ("phpexcel".DIRECTORY_SEPARATOR."Classes".DIRECTORY_SEPARATOR."PHPExcel.php");

class PAExcelReader{
  private $file;
  private $data;
  private $reader;
  
  public function __construct($fileName = null){
    if($fileName != null){
      $fileType = PHPExcel_IOFactory::identify($fileName);
      $this->reader = PHPExcel_IOFactory::createReader($fileType);
      $this->file = $this->reader->load($fileName);
      $this->data = $this->file->getActiveSheet()->toArray();
    }
    else{
      throw new Exception("Błąd podczas importu pliku.");
    }
  }
  
  public function getFile(){
    return $this->file;
  }
  
  public function getData(){
    return $this->data;
  }
  
  public function getReader(){
    return $this->reader;
  }
}
